package info.tsukaworld.gui;

import acm.graphics.GCompound;
import acm.graphics.GLabel;
import acm.graphics.GRect;
import java.awt.Font;

public class TopHUD extends HUDComponent
{
    public static final int TOP_HUD_HEIGHT = 40;
    private GLabel title;
    private GLabel message;
    public TopHUD()
    {
        add(new GRect(13 * 50, TOP_HUD_HEIGHT), 0, 0);
        title = new GLabel("Version 1");
        title.setFont( new Font("Bold", Font.BOLD, 16 ));
        add( title, PlayArea.MAX_WIDTH / 4 - title.getWidth()/2, 20);
        
        message = new GLabel("Click anywhere.");
        message.setFont( new Font("Bold", Font.BOLD, 16 ));
        add(message,3 * PlayArea.MAX_WIDTH / 4 - title.getWidth()/2, 20);
        
    }
    
    void step()
    {
       if( title != null )
       {
           title.setLabel("Mouse At: " + Game.mouseListener.getX() + " " + Game.mouseListener.getY());
       }
       
       if( Game.mouseListener.getClickedX() != 0 || Game.mouseListener.getClickedY() != 0)
       {
           if( Game.mouseListener.getClickedY() <= 40 )
           {
               remove(message);
               message.setLabel("Clicked on the Top HUD.");
               add(message,3 * PlayArea.MAX_WIDTH / 4 - message.getWidth()/2, 20);
           }
           else if( Game.mouseListener.getClickedY() > 690 )
           {
               remove(message);
               message.setLabel("Clicked on the bottom HUD.");
               add(message,3 * PlayArea.MAX_WIDTH / 4 - message.getWidth()/2, 20);
           }
           else
           {
               //Removes the HUD offset
               int boardY  = Game.mouseListener.getClickedY() - 40;
               remove(message);
               message.setLabel("Clicked on tile [" + boardY/50 +  "," +
                   (Game.mouseListener.getClickedX() / 50) + "]" );
               add(message,3 * PlayArea.MAX_WIDTH / 4 - message.getWidth()/2, 20);
           }
        }
      
    }
}